import { fromLonLat } from "ol/proj";

let featureObj = {
  // 类型判定 这里type=point/solar
  tyepJudge: function (feature) {
    if (feature.get("type") === "typhoonPoint") {
      return "typhoonPoint";
    } else if (feature.get("type") === "typhoonSolar") {
      return "typhoonSolar";
    } else {
      return "other";
    }
  },
  // 台风点点击事件
  typhoonPointClick: function (feature) {
    console.log('点点击', feature);
  },
  // 台风点hover事件
  typhoonPointHover: function (feature) {
    console.log(feature)
    let point = feature.get('point')
    this.typhoonInfo = point
    let positon = fromLonLat([point.lng, point.lat])
    this.overlay && this.overlay.setPosition(positon)
    this.map.getTargetElement().style.cursor = "pointer";
    if (this.lastPointFeature) {
      this.lastPointFeature.getStyle().getImage().setRadius(4);
      this.lastPointFeature.changed();
    }
    feature.getStyle().getImage().setRadius(8);
    feature.changed(); // 触发更新
    this.lastPointFeature = feature;
  },
  typhoonSolarClick: function (feature) {
    console.log('风圈点击', feature)
  },
  typhoonSolarHover: function(feature) {
    console.log('风圈hover', feature)
  },
  otherClick: function(feature) {
    console.log('其它要素点击')
  },
  otherHover: function(feature) {
    console.log('其它要素hover')
  }
};
export default featureObj;
